package rok3.zesp.projekt.p;

import rok3.zesp.projekt.Settings;
import rok3.zesp.projekt.models.interfaces.Resizable;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;

public class BottomPanel extends Group implements Resizable {
	Skin skin;
	private Image bg;
	private TextField tf;

	public BottomPanel(Skin skin) {
		this.skin = skin;
		this.setHeight(50);

		this.addActor(getBackground());
		this.addActor(getTextField());
		
		Settings.register(this);
	}

	public Image getBackground() {
		if (bg == null) {
			bg = new Image(new Texture(Gdx.files.internal("test/bg.png")));
			bg.setPosition(0, 0);
			bg.setWidth(Gdx.graphics.getWidth());
			bg.setHeight(this.getHeight());
		}
		return bg;
	}

	public TextField getTextField() {
		if (tf == null) {
			tf = new TextField("", skin);
			tf.setPosition(0, 10);
			tf.setWidth(250);
			tf.setHeight(this.getHeight() - 20);
		}
		return tf;
	}

	@Override
	public void resize(float ratioX, float ratioY) {
		// for (Actor actor : this.getChildren()) {
		// actor.setWidth(actor.getWidth()*Settings.scale_ratioX);
		// actor.setHeight(actor.getHeight()*Settings.scale_ratioY);
		// }
		this.setScaleX(ratioX);
		this.setScale(ratioY);
	}
}
